import pandas as pd
import numpy as np
import math
import matplotlib.pyplot as plt
import scipy.stats as stats

# 读取 house-votes-84.csv 文件的前五条数据
df = pd.read_csv('house-votes-84.csv').head()

# 计算正态分布曲线数据
u = 0   # 均值μ
sig = math.sqrt(1)  # 标准差δ
x_norm = np.linspace(u - 4*sig, u + 4*sig, num=50000)
y_norm = np.exp(-(x_norm - u) ** 2 /(2* sig **2))/(math.sqrt(2*math.pi)*sig)

# 假设从数据中提取某个特征用于贝塔分布，这里只是示例，实际情况需根据数据调整
data_for_beta = df.iloc[:, 0]  # 假设取第一列数据
x_beta = np.linspace(0, 1, num=50000)
y_beta = stats.beta.pdf(x_beta, 4, 2)

# 绘制图形
fig = plt.figure()
plt.plot(x_norm, y_norm, "k-", linewidth=2, label='Normal Distribution')
plt.plot(x_beta, y_beta, "b-", linewidth=2, label='Beta Distribution')
plt.grid(True)
plt.legend()
plt.show()